package org.jsola.hr.helper;

import org.jsola.hr.dto.TransferAccountsBankBatchAddDTO;
import org.jsola.hr.dto.TransferAccountsBankBatchUpdateDTO;
import org.jsola.hr.entity.TransferAccountsBankBatchDO;
import org.jsola.hr.query.TransferAccountsBankBatchQuery;
import org.jsola.hr.service.ITransferAccountsBankBatchService;
import org.jsola.hr.vo.TransferAccountsBankBatchVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 转账批次(平安银行)
 *
 * @author zhr
 */
@Component
public class TransferAccountsBankBatchTestHelper extends BaseTestHelper {
    
    @Autowired
    private ITransferAccountsBankBatchService transferAccountsBankBatchService;

    /**
     * 生成add测试数据
     * @return TransferAccountsBankBatchAddDTO
     */
    public TransferAccountsBankBatchAddDTO getTransferAccountsBankBatchAddDTO(){
        TransferAccountsBankBatchAddDTO transferAccountsBankBatchAddDTO = new TransferAccountsBankBatchAddDTO();
        transferAccountsBankBatchAddDTO.setBatchId(getRandomValue("varchar",32));
        transferAccountsBankBatchAddDTO.setThirdVoucher(getRandomValue("varchar",20));
        transferAccountsBankBatchAddDTO.setAgreeNo(getRandomValue("varchar",50));
        transferAccountsBankBatchAddDTO.setBusiType(getRandomValue("varchar",5));
        transferAccountsBankBatchAddDTO.setPayType(getRandomValue("varchar",1));
        transferAccountsBankBatchAddDTO.setCurrency(getRandomValue("varchar",3));
        transferAccountsBankBatchAddDTO.setSrcAccNo(getRandomValue("varchar",20));
        transferAccountsBankBatchAddDTO.setTotalNum(getRandomValue("varchar",10));
        transferAccountsBankBatchAddDTO.setTotalAmount(getRandomValue("varchar",20));
        transferAccountsBankBatchAddDTO.setSettleType(getRandomValue("varchar",1));
        transferAccountsBankBatchAddDTO.setBatchOrdRemark(getRandomValue("varchar",100));
        transferAccountsBankBatchAddDTO.setBussFlowNo(getRandomValue("varchar",32));
        transferAccountsBankBatchAddDTO.setBstt(getRandomValue("varchar",1));
        transferAccountsBankBatchAddDTO.setOthBankFlag(getRandomValue("varchar",1));
        transferAccountsBankBatchAddDTO.setHostFlowNo(getRandomValue("varchar",32));
        transferAccountsBankBatchAddDTO.setHostBusinessNo(getRandomValue("varchar",32));
        return transferAccountsBankBatchAddDTO;
    }


    /**
     * 生成update测试数据
     * @return TransferAccountsBankBatchUpdateDTO
     */
    public TransferAccountsBankBatchUpdateDTO getTransferAccountsBankBatchUpdateDTO(TransferAccountsBankBatchVO transferAccountsBankBatchVO){
        return transferAccountsBankBatchService.selectDOById(transferAccountsBankBatchVO.getId(), SITE_ID).to(TransferAccountsBankBatchUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return TransferAccountsBankBatchQuery
     */
    public TransferAccountsBankBatchQuery getTransferAccountsBankBatchQuery() {
        TransferAccountsBankBatchQuery transferAccountsBankBatchQuery = new TransferAccountsBankBatchQuery();
        List<TransferAccountsBankBatchDO> transferAccountsBankBatchDOList = transferAccountsBankBatchService.list(new TransferAccountsBankBatchDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(transferAccountsBankBatchDOList)) {
            TransferAccountsBankBatchDO transferAccountsBankBatchDO = transferAccountsBankBatchDOList.get(0);
            transferAccountsBankBatchQuery = transferAccountsBankBatchDO.to(TransferAccountsBankBatchQuery.class);
        }
        return transferAccountsBankBatchQuery;
    }

    /**
     * 保存示例
     * @return TransferAccountsBankBatchVO
     */
    public TransferAccountsBankBatchVO saveTransferAccountsBankBatchExample(){
        TransferAccountsBankBatchAddDTO addDTO = this.getTransferAccountsBankBatchAddDTO();
        TransferAccountsBankBatchVO transferAccountsBankBatchVO = transferAccountsBankBatchService.save(addDTO,buildTokenUser());
        return transferAccountsBankBatchVO;
    }


}

